Repository navigation
fix(reconciliation): explain broker-assisted fees and valuation basis - #496
Merged
Merged
Conversation
Split broker-assisted sell and regulatory fees out of statement reconciliation residuals using a dated Firstrade fee schedule, and report the balances-versus-positions valuation basis difference separately. The TAF increase is deferred to 2029 per SR-FINRA-2026-020.
Collect the balance-endpoint long_stock_value as a distinct fact. When the top-level and result values conflict, withhold the value and mark it ambiguous instead of discarding the whole collection. The publisher persists it only when include_valuation_basis is enabled, because the console schema does not yet accept the extra key.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AI assistance
Grok Bot (an AI agent working for the repository owner) wrote the code, tests and documentation in this PR. It was not merged or deployed by the agent; human review is pending.
What changed
Replaces #495 with an identical tree on a clean branch cut from the current
main. #495 could not merge because its first commit (409120b) fails the commitlint convention and the repo does not allow force-pushing a branch under review. The final tree equals #495 head 2786474 (git diff 2786474 HEADis empty); the history is squashed into 2 Conventional Commits. #495 is closed and its branch is kept.Problem: two Firstrade reconciliation differences (August 19.96 and total assets 0.06) were reported as unexplained. They come from the broker-assisted order fee (19.95) plus SEC Section 31 / FINRA TAF regulatory fees on margin-sellout sells, and from a price-basis difference between the balance API
long_stock_valueand summed position market values.Behaviour after this PR:
BROKER/DEALER ORDER(includingMARGIN SELLOUT) are split into broker-assisted fee, SEC fee and TAF. Unrounded fees are summed and rounded up to the cent with a 0.01 minimum; a residual within +/-0.01 isexplained.verified_through(2026-11-01) makes any later trade dateunsupported, because the SEC FY2027 Section 31 rate is not published.Datecolumn is treated as the trade date (checked againstEXEC TIMEandS/D; the 8/28 IBIT row settles 8/31). Non-positive quantity or price isunsupported.valuation_basis_differencewith tolerance min(max(0.10, 0.1% of market value), 25.00), an optional position-quantity cross-check, andunexplainedfor an empty positions list with a non-zero balance.long_stock_valueas its own fact; a conflicting value is flagged (long_stock_value_ambiguous) instead of failing the whole collection. The snapshot persists it only behind an explicit opt-in.How verified
git diff 2786474 HEADis empty (tree d412136b4134), so the content is exactly what fix(reconciliation): explain broker-assisted fees and valuation basis #495 reviewed.pytest tests/test_statement_reconciliation.py tests/test_account_facts_readonly.py tests/test_account_facts_publisher.py: 122 passed.ruff check(0.15.20, the locked version) passes on the whole repo excludingexternal.engineering-governance.ymloverorigin/main..HEAD: 0 problems on both commits. The PR title also passes.quant_platform_kit, the same on the base commit); CI runs it.Supersedes #495.